
var n_prs = "100002";


var o_wn = window;
var ie = document.all;
var s_url = "http://supermedia.mk/server/ac/";
var s_img_url = "http://supermedia.mk/server/js/";
var op = 0;
var s_prm = "";
var a_prm = new Array();
var a_words = new Array();
var a_renew = new Array();
var a_words_ids = new Array();
var a_evt_names = new Array("onmouseover","onmouseout","onclick")
var slct_wrd_count = 0;
var wrd_count;
var hgl_interv;
var load_interv;
var tt_hid_tmr;
var opacity = 94;
var b_ad_loaded;
var tt_ifr_id = "ifrTTP";
var act_word;
var act_itm_ref;

addHandler(o_wn, 'load', LoadPresetData);

function addHandler(obj, evType, handler)
{ 
	if (obj.addEventListener) { 
	   obj.addEventListener('DOMContentLoaded', handler, false);
	   return true;
	 } else if (obj.attachEvent) { 
	   var r = obj.attachEvent("on"+evType, handler);
	   return r;
	 } else { 
	   return false; 
	 }
}


function LoadData(s_url) 
{ 
  try { 
		s = document.createElement("script"); 
		s.src = s_url; 
		s.language = "Javascript"; 
		s.type = "text/javascript"; 
		if(document.body) 
			document.body.appendChild(s); 
		else 
			jsTimer = winObj.setTimeout("LoadData('" + s_url + "')",1000);
  } catch(e) { 
  	return -1;
  } 
}


function LoadPresetData()
{
	if (!o_wn.n_prs) return;
	o_wn.setTimeout('LoadData(s_url + "keywords.php?pid=45");',500);
}

function getDomain(str) {
    if (str == null || str.length == 0) return "";
    str = str.toLowerCase();
    str = str.replace(/https:\/\//, '').replace(/http:\/\//, '');
    var i = str.indexOf("/");
    if (i > -1) str = str.substring(0, i);
    var parts = str.split('.');
    var len = parts.length;
    if (len < 3) return str;
    var lastPart = parts[len - 1];
    var secondPart;
    secondPart = parts[len - 2];
    var two = 2;
    if (lastPart == "uk" && secondPart == "co")++two;
    if (len >= 0) return 'www.' + parts.splice(len - two, two).join('.');
    return "";
}
function DoChanges()
{	
	if (o_wn.navigator.userAgent.indexOf("Mozilla")==-1)
		if (o_wn.navigator.userAgent.indexOf("Opera")!=-1)
			op = 1;
		else
			return;
	
	if(s_prm) a_prm = s_prm.split("|"); 
	if(!a_prm[0] || a_prm[0].length == 0) return; 
	a_prm[1] = a_prm[1]?a_prm[1]:"#0000FF"; 
	a_prm[2] = "310";	
	a_prm[3] = a_prm[3]?a_prm[3]:"About It Ad";	
	a_prm[5] = a_prm[5]?a_prm[5]:"#000033"; 
	a_prm[7] = a_prm[7]?a_prm[7]:"#FF6600";	
	a_prm[6] = a_prm[6]?a_prm[6]:a_prm[7]; 
	a_prm[8] = a_prm[8]?a_prm[8]:"#0000FF";	
	a_prm[9] = a_prm[9]?a_prm[9]:"1";
	a_prm[10] = "230";
	
	var o_div = document.createElement("DIV");
	AddEvntHandlers(o_div,a_evt_names,new Array(TTHideCancel,TTHideDelayed,TTClick));
	document.body.appendChild(o_div);
	o_div.setAttribute("id", "msgHolder");
	o_div.style.cssText = "z-index:10; position:absolute; display:none; filter:alpha(opacity=" + opacity + "); opacity: " + opacity/100 + "; ";
	o_div.innerHTML = "<iframe name=\"\" id=\"" + tt_ifr_id + "\" frameborder=\"0\"  " +
										" src=\"about:blank\" scrolling=\"no\" marginwidth=\"0\" marginheight=\"0\" allowtransparency=\"true\"></iframe>";
	
	var o_ifr_doc = TTiFrmDocRef();
	
	if (o_ifr_doc)
	{
		with(o_ifr_doc) {
			write("<html><head><meta http-equiv=\"Pragma\" content=\"no-cache\"><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">");
			write("<style type=\"text/css\"> ");
			write(" .TT_Main {font-family:Arial; border:1px solid #000000 } ");
			write(" .TT_Header { color:"+a_prm[5]+"; font-size:12px; height:27px; vertical-align:top; padding:0px 3px 2px 3px } ");
			write(" .TT_Header_Txt { color:#fff; font-size:12px; text-shadow:0px 0px 2px rgba(0, 0, 0, 0.60);} ");
			write(" .TT_Ttl { color:"+a_prm[6]+"; text-decoration:underline; font-weight:bold; } ");
			write(" .TT_Body { color:"+a_prm[7]+"; font-size:12px; text-decoration:none; cursor:pointer } ");
			write(" .TT_Link { color:"+a_prm[8]+"; font-size:11px; text-decoration:underline; cursor:pointer } ");
			write(" .NoRep { background-repeat:no-repeat } a { text-decoration:none; color: #000033; } img { border-style:none; cursor:pointer; } ");
			write("</style><script language='javascript'>var tt_cont = new Array(); a_img = new Array(); ");
			write("a_img[0] = new Image(); a_img[0].src=parent.s_img_url+'Loading1.gif';  ");
			write("a_img[1] = new Image(); a_img[1].src=parent.s_img_url+'int_quest.gif';  ");
			write("a_img[2] = new Image(); a_img[2].src=parent.s_img_url+'int_x.png';  ");			
			write("function LoadData(s_url) { try { "); 
			write("s = document.createElement('script'); s.src=s_url; s.language = 'Javascript'; ");
			write("s.type = 'text/javascript'; if(document.body) document.body.appendChild(s); else jsTimer = window.setTimeout(\"LoadData('\" + s_url + \"')\",1000); ");
			write("} catch(e) { return -1; } }");
			write("function writeHTML() {	var o_p=parent; var ln=tt_cont.length; ");
			write("tt_cont[ln]=new Array(); tt_cont[ln][0]=parent.act_word; tt_cont[ln][1]=brDescriptions[0]; tt_cont[ln][2]=brURLs[0];");
			write("tt_cont[ln][3]=brTitles[0]; tt_cont[ln][4]=Date.parse(new Date()); tt_cont[ln][5]=brRedirects[0]; tt_cont[ln][6]=brFile[0];  tt_cont[ln][7]=brTransparent[0]; tt_cont[ln][8]=brWidth[0]; tt_cont[ln][9]=brHeight[0]; tt_cont[ln][10]=bgColor[0]; tt_cont[ln][11]=brColor[0]; tt_cont[ln][12]=brRadius[0];");
			write("if (o_p.a_renew && o_p.a_renew.length == 3) ");
			write("o_p.TTRenew(o_p.act_word,o_p.a_renew[0],o_p.a_renew[1],o_p.a_renew[2]); } ");
			write("</script></head><body>"); 
			write("<table id='msgTbl' class='TT_Main' cellpadding='0' cellspacing='0' onclick='parent.TTClick()'>");
			//write("<tr  id='boxhead'><td class='NoRep' style='width:8px; height:8px;background-position:left top; background-image: url(\""+parent.s_img_url+"int_topBorderLeft.gif\");'></td><td style='background-image: url(\""+parent.s_img_url+"int_topBorder.gif\");width:100%;'></td><td class='NoRep' style='width:8px;background-position:right top;background-image: url(\""+parent.s_img_url+"int_topBorderRight.gif\");'></td></tr>");
			write("<tr  id='boxtitle'><td colspan='3'><div id='poup_head' style='background-image: url(\""+parent.s_img_url+"head_pattern.jpg\"); '><table class='TT_Header' cellpadding='0' cellspacing='0' style='width:100%;'><tr><td style='vertical-align:top; text-align:left; width:150px; padding:6px 0px 0px 6px; font-weight:bold;'><a href='http://supermedia.mk/server' target='_blank' class='TT_Header_Txt'>"+"supermedia.mk"+"</a></td><td style='width:27px; float:right; padding-top:2px'><img id='imgX' onMouseOver='parent.status=\"Close\"' onMouseOut='parent.status=\"\"' style='float:right' onclick='parent.TTHide();' /></td></tr></table></div></td></tr>");
			write("<tr><td colspan='3'><div id='boxbody' class='TT_Body' style='vertical-align:top;'>");
			write("<div id='ttTtl' style='padding:1px 10px'></div><div id='ttBody' style='padding:0px 10px;'></div><div id='ttFile' style='padding:2px 4px 1px 4px; text-align: center;'></div><div id='ttLnk' style='padding:2px 4px 1px 4px'></div>");
			write("</div></td></tr>");
			//write("<tr   id='boxfooter'><td class='NoRep' style='height:8px; background-image: url(\""+parent.s_img_url+"int_btmBorderLeft.gif\");background-position:left bottom;'></td><td style='background-image: url(\""+parent.s_img_url+"int_btmBorder.gif\");'></td><td class='NoRep' style='background-image: url(\""+parent.s_img_url+"int_btmBorderRight.gif\");background-position:right bottom;'></td></tr>");
			write("</table></body></html>");
			!ie ? close() : "";
		}
		if (!a_words || a_words.length==0) return;
		
		var o_ifr_win = TTiFrmWinRef();
		if (o_ifr_win) {
			//PrepareTTImg("imgQuest",o_ifr_win.a_img[1]);
			PrepareTTImg("imgX",o_ifr_win.a_img[2]); 
		}
		hgl_interv = o_wn.setInterval("DoHighlight()",9);
		o_wn.status='';
	}
}


function PrepareTTImg(s_img_id,o_img)
{
	var o_ifr_doc = TTiFrmDocRef();
	if (!o_ifr_doc || !o_img || !s_img_id) return;
	var img = o_ifr_doc.getElementById(s_img_id);
	if (img) img.src = o_img.src; else img.style.display = "none";
}


function TTSetBody(tt_ttl,tt_body,tt_lnk,ref_lnk,tt_file,tt_transparent, tt_width, tt_height, tt_bgcolor, tt_brcolor, tt_brradus)
{
	
	tt_width = typeof tt_width !== 'undefined' ? tt_width : a_prm[2]-10;
	tt_height = typeof tt_height !== 'undefined' ? tt_height : a_prm[10];
	

	
	var o_ifr_win = TTiFrmWinRef();
	var o_ifr_doc = TTiFrmDocRef();
	if (!o_ifr_doc) return;
	var div_ttl = o_ifr_doc.getElementById("ttTtl");
	var div_body = o_ifr_doc.getElementById("ttBody");
	var div_lnk = o_ifr_doc.getElementById("ttLnk");
	var div_file = o_ifr_doc.getElementById("ttFile");
	
	var t_boxhead = o_ifr_doc.getElementById("boxhead");
	var t_boxtitle = o_ifr_doc.getElementById("boxtitle");
	var t_boxfooter = o_ifr_doc.getElementById("boxfooter");
	var div_boxbody = o_ifr_doc.getElementById("boxbody");
	
	var lnk_pref = "<a href='" + ref_lnk + "' target='_blank' ";
	var b_heb = DetectHeb(tt_body);
	
	if (!div_ttl || !div_body || !tt_body || !div_lnk) return;
	if (tt_ttl) {
		if (b_heb) div_ttl.dir = "rtl"; else div_ttl.dir = "ltr";
		div_ttl.innerHTML = lnk_pref + " class='TT_Ttl'>" + tt_ttl + "</a>";
		div_ttl.style.display="block";
	}
	else 
		div_ttl.style.display="none";
		div_lnk.style.display="none";
	if (b_heb) div_body.dir = "rtl"; else div_body.dir = "ltr";
	div_body.innerHTML = lnk_pref + " class='TT_Body'>" + tt_body + "</a>";

	if (tt_file) {
		div_file.innerHTML = '';
		var exts = tt_file.split('.');
		var ext = exts[1];
		if (ext == 'swf') {
			var fileObj = "<object width='"+tt_width+"' height='"+tt_height+"'><param name='wmode' value='transparent'><param name='file_obj' value='http://supermedia.mk/server/" + tt_file + "'>" + "<embed src='http://supermedia.mk/server/" + tt_file + "' type='application/x-shockwave-flash' width='"+tt_width+"' height='"+tt_height+"' wmode='transparent'></embed></object>";
			div_file.innerHTML = lnk_pref + " class='TT_Link'>" + fileObj + "</a>";
		} else {
			div_file.innerHTML = lnk_pref + " class='TT_Link'>" + "<img alt='' width='"+tt_width+"' height='"+tt_height+"' src='http://supermedia.mk/server/" + tt_file + "' /></a>";
			div_lnk.style.display="block";
		}
	}
	var img = o_ifr_doc.getElementById("imgLoad"); 
	if (img && o_ifr_win) img.src = o_ifr_win.a_img[0].src;	
	
	var o_ifr = GetObj(tt_ifr_id);
	if(parseInt(tt_width) < 200) tt_width = 200;
	jQuery(o_ifr).attr("width", parseInt(tt_width) + 10); 
	
	var msg_ref = o_ifr_doc.getElementById("msgTbl");
	o_ifr.setAttribute("height", msg_ref.offsetHeight);
	//$(o_ifr).attr("height", parseInt(tt_height) + 50); 
	//console.log($(o_ifr).attr("width"));
	
	tt_transparent = typeof tt_transparent !== 'undefined' ? tt_transparent : false;
	if(tt_transparent == 1){
		transparentBox();
	}else
	{
		solidBox(tt_bgcolor, tt_brcolor, tt_brradus);
	}
}

function transparentBox(){
	var o_ifr_doc = TTiFrmDocRef();
	if (!o_ifr_doc) return;
	var t_boxhead = o_ifr_doc.getElementById("boxhead");
	var t_boxtitle = o_ifr_doc.getElementById("boxtitle");
	var t_boxfooter = o_ifr_doc.getElementById("boxfooter");
	var div_boxbody = o_ifr_doc.getElementById("boxbody");
	var t_msgTbl =  o_ifr_doc.getElementById("msgTbl");

	jQuery(t_boxhead).hide();
	jQuery(t_boxtitle).hide();
	jQuery(t_boxfooter).hide();
	jQuery(t_msgTbl).css("border","none");
	jQuery(t_msgTbl).css("background","transparent");
}


function solidBox(tt_bgcolor,tt_brcolor, tt_brradus){
	var o_ifr_doc = TTiFrmDocRef();
	if (!o_ifr_doc) return;
	var t_boxhead = o_ifr_doc.getElementById("boxhead");
	var t_boxtitle = o_ifr_doc.getElementById("boxtitle");
	var t_boxfooter = o_ifr_doc.getElementById("boxfooter");
	var div_boxbody = o_ifr_doc.getElementById("boxbody");
	var t_msgTbl =  o_ifr_doc.getElementById("msgTbl");
	
	var poup_head = o_ifr_doc.getElementById("poup_head");

	jQuery(t_boxhead).show();
	jQuery(t_boxtitle).show();
	jQuery(t_boxfooter).show();
	
	if(!tt_bgcolor) tt_bgcolor = "#fff";
	if(!tt_brcolor) tt_brcolor = "#000";
	
	
	jQuery(t_msgTbl).css("-moz-border-radius", tt_brradus+"px "+tt_brradus+"px "+tt_brradus+"px "+tt_brradus+"px");
	jQuery(t_msgTbl).css("-webkit-border-radius", tt_brradus+"px "+tt_brradus+"px "+tt_brradus+"px "+tt_brradus+"px");
	jQuery(t_msgTbl).css("border-radius", tt_brradus+"px "+tt_brradus+"px "+tt_brradus+"px "+tt_brradus+"px");
	
	jQuery(poup_head).css("-moz-border-radius", tt_brradus+"px "+tt_brradus+"px 0px 0px");
	jQuery(poup_head).css("-webkit-border-radius", tt_brradus+"px "+tt_brradus+"px 0px 0px");
	jQuery(poup_head).css("border-radius", tt_brradus+"px "+tt_brradus+"px 0px 0px");
	
	jQuery(t_msgTbl).css("border","1px solid "+tt_brcolor);
	jQuery(t_msgTbl).css("background", tt_bgcolor);

}

function TTiFrmDocRef()
{
	/*
if (op) 	
		return GetObj(tt_ifr_id).document;
	else
*/
		return (ie ? document.frames[tt_ifr_id].document : GetObj(tt_ifr_id).contentDocument);
}


function TTiFrmWinRef()
{
	return (ie&&!op ? document.frames[tt_ifr_id].window : GetObj(tt_ifr_id).contentWindow);
}


function TTShow(event)
{	
	var o_child, over, word, tt_data_ref, doc_el;
	var elemOfsX = elemOfsY = y_co = scrl_top = 0;
	var ev = event;
	var msg_div = GetObj("msgHolder");
	if (!msg_div || !ev) return;
	var elem1 = elem = ev.srcElement ? ev.srcElement : ev.target;
	var do_renew = 0;
	var o_nd_type = ie ? 1 : elem1.ELEMENT_NODE;
	TTHideCancel(1);
	
	while(elem1.nodeType != o_nd_type)
		elem1 = elem1.parentNode;
	
	if (elem1.offsetParent)
		while (elem1.offsetParent) {
			elemOfsX += elem1.offsetLeft;
			elemOfsY += elem1.offsetTop;
			elem1 = elem1.offsetParent;
		}
	
	word = (ie||op)?elem.innerText:elem.textContent;
	
	var o_ifr = GetObj(tt_ifr_id);
	var o_ifr_doc = TTiFrmDocRef();
	var msg_ref = o_ifr_doc.getElementById("msgTbl");
	
	if(!msg_ref) return;
	
	tt_data_ref = TTGetCont(word);

	
	if (tt_data_ref && tt_data_ref[4] && (Date.parse(new Date()) - tt_data_ref[4] > 540000)) {
			TTClearCont(word);
			tt_data_ref = null;
	} 
	
	
	if (!tt_data_ref || tt_data_ref.length == 0) {
		
		var div_file = o_ifr_doc.getElementById("ttFile");
		jQuery(div_file).html("")
		
		b_ad_loaded = 0;
		load_interv = o_wn.setInterval("ChkAdLoad()",4500);
		tt_data_ref = new Array("","<table><tr valign='middle'><td>&nbsp;<img id='imgLoad' style='width:20px; height:20px;' /></td><td class='TT_Body'>&nbsp;<b>Loading Data...</b></td></tr><table>","","",0,"javascript:void(0)","","","","","#fff","#000","0");
		act_word = word;
		var wid = GetWordId(act_word);
		var o_ifr_win = TTiFrmWinRef(); 
		if (o_ifr_win) { 
			var rnd = Math.floor(Math.random() * 100000); 
			var loc; 
			try { loc = top.location; } catch(e) { loc = document.location; } 
			o_ifr_win.LoadData(s_url+"ad_data.php?pid=45&bl="+escape(loc)+"&key="+word+"&word_id="+wid+"&tmp="+rnd); 
		} 
		do_renew = 1; 
	}
	TTSetBody(tt_data_ref[3],tt_data_ref[1],tt_data_ref[2],tt_data_ref[5],tt_data_ref[6],tt_data_ref[7],tt_data_ref[8],tt_data_ref[9],tt_data_ref[10],tt_data_ref[11],tt_data_ref[12]);
	act_itm_ref = tt_data_ref; 
	elem.style["borderBottomWidth"] = a_prm[9]+"px"; 
	elem.setAttribute("href",tt_data_ref[5]); 
	msg_div.style.display = "inline"; 

	
	doc_el = document.documentElement; 
	scrl_top = doc_el.scrollTop ? doc_el.scrollTop : document.body.scrollTop; 
	
	over = (elemOfsX + msg_div.offsetWidth) - document.body.offsetWidth + 10; 
	if (over<0) over=0; 
	
	if (over > 0) 
		elemOfsX -= msg_div.offsetWidth; 
	
	if (elemOfsY - scrl_top < msg_div.offsetHeight + 10) 
		y_co = elemOfsY + elem.offsetHeight - 2; 
	else 
		y_co = elemOfsY - msg_div.offsetHeight; 
	
	if (do_renew) { 
		a_renew[0] = elem; 
		a_renew[1] = elemOfsY; 
		a_renew[2] = scrl_top; 
	} 
	
	msg_div.style.left = (elemOfsX + "px");
	msg_div.style.top = (y_co + "px");
}


function TTRenew(word,elem,elem_top,scrl_top)
{	
	if (b_ad_loaded) return;
	var msg_div = GetObj("msgHolder");
	if (!msg_div) return;
	var prev_height = msg_div.offsetHeight;
	var prev_top = msg_div.offsetTop;
	var tt_data_ref = TTGetCont(word);
	if (!tt_data_ref || tt_data_ref.length == 0) 
		tt_data_ref = new Array("","See Google search results about <b><u>" + act_word + "</u></b>","www.google.com",act_word,0,
														"http://www.google.com/search?q="+act_word+"&ie=utf-8&oe=utf-8&aq=t","","","","","#fff","#000","0");
	act_itm_ref = tt_data_ref;

	TTSetBody(tt_data_ref[3],tt_data_ref[1],tt_data_ref[2],tt_data_ref[5],tt_data_ref[6],tt_data_ref[7],tt_data_ref[8],tt_data_ref[9],tt_data_ref[10],tt_data_ref[11],tt_data_ref[12]);
	elem.setAttribute("href",tt_data_ref[5]);
	
	var o_ifr = GetObj(tt_ifr_id);
	var o_ifr_doc = TTiFrmDocRef();
	var msg_ref = o_ifr_doc.getElementById("msgTbl");
	o_ifr.setAttribute("height", msg_ref.offsetHeight);
	
	if(elem_top < prev_height)
		y_co = prev_top;
	else {
		y_co = elem_top - msg_div.offsetHeight;
		if (y_co - scrl_top < 10)
			y_co = elem_top + elem.offsetHeight - 2;
	}
	msg_div.style.top = (y_co + "px");
	b_ad_loaded = 1;
	ClearAdLoadInterv();
}


function TTClick()
{
	var o_n_win;
	if (act_itm_ref) { 
		TTClearCont(act_itm_ref[0]);
		act_itm_ref = null;
	}
}

function TTHideDelayed(event)
{
	TTSetOpacity(opacity);
	tt_hid_tmr = o_wn.setTimeout("TTHide()",1500);
	
	var ev = event;
	if (ev) {
		var elem = ev.srcElement ? ev.srcElement : ev.target;		
		if (elem && (elem.innerText||elem.textContent)) 
				elem.style['borderBottomWidth'] = '1px';
	}
}

function TTHideCancel(b_ovr_under)
{
	o_wn.clearTimeout(tt_hid_tmr);
	if (b_ovr_under!=1)
		TTSetOpacity(100);
}


function TTHide()
{	
	var msg_div = GetObj("msgHolder");
	if (msg_div) 
		msg_div.style.display = "none";
}


function TTGetCont(word)
{
	var i=0, ret_val;
	var tt_cont = TTiFrmWinRef().tt_cont;
	if (!tt_cont) return;
	while (i<tt_cont.length && !ret_val) {
		if (tt_cont[i] && word.toLowerCase()==tt_cont[i][0].toLowerCase()) 
			ret_val = tt_cont[i];
		i++;
	}
	return ret_val;
}


function TTClearCont(word) 
{
	var i=j=0;
	var tt_cont_tmp = new Array();
	var tt_cont = TTiFrmWinRef().tt_cont;
	if (!tt_cont) return;
	while (i<tt_cont.length) {
		if (tt_cont[i] && word.toLowerCase()==tt_cont[i][0].toLowerCase()) 
			j++;
		i++;
		tt_cont_tmp[j] = tt_cont[i];
	}
	TTiFrmWinRef().tt_cont = tt_cont_tmp;
}


function TTSetOpacity(ie_opaticy) 
{
	var msg_div = GetObj("msgHolder");
	if (msg_div) {
		if (ie && !op)
			msg_div.style.filter = "alpha(opacity="+ie_opaticy+")";
		else
			msg_div.style.opacity = ie_opaticy/100;
	}
}


function ChkAdLoad()
{
	ClearAdLoadInterv();
	if (!b_ad_loaded) {
		TTRenew(act_word,a_renew[0],a_renew[1],a_renew[2]);
		b_ad_loaded = 1;
	}
}

function ClearAdLoadInterv()
{
	o_wn.clearInterval(load_interv);
	load_interv = null;
}


function DoHighlight()
{
		if (slct_wrd_count == a_words.length) 
			o_wn.clearInterval(hgl_interv);
		else {
			try { 
				wrd_count=0;
				a_words[slct_wrd_count] = decodeURI(a_words[slct_wrd_count]);				
				HighlRecursive(document.body, a_words[slct_wrd_count]);
			} catch(e) { }
			slct_wrd_count++;
		}
}

var curWord = "";


function HighlRecursive(main_nd, srch_word)
{
	if(srch_word==curWord) return;
	
	var o_chld_nd, o_pr_nd, s_nd_nm, tmp_nd_val;
	var i,j,k,m, srch_word_cnt = 0;
	var hi_txt, hi_txt_nd, hi_txt_nd_hold, s_txt;
	var evHandlers = new Array(TTShow, TTHideDelayed, TTClick);
	if(main_nd.childNodes && main_nd.childNodes.length && srch_word.length)
	{
		s_txt = ie ? main_nd.innerText : main_nd.textContent;
		if (s_txt.toLowerCase().indexOf(srch_word.toLowerCase()) == -1)
			return;
		for (i=0; i<main_nd.childNodes.length && srch_word_cnt<4; i++)
	  {
		  o_chld_nd = main_nd.childNodes[i];
			o_pr_nd = o_chld_nd.parentNode;		
			if (!o_pr_nd || o_pr_nd.getAttribute("tpi"))
				return;
			s_nd_nm = o_pr_nd.nodeName;
			if (s_nd_nm.indexOf("H")==0 || s_nd_nm=="SCRIPT" || s_nd_nm=="STYLE" || s_nd_nm=="A" || s_nd_nm=="TEXTAREA" || s_nd_nm=="INPUT")
		  	return; 
		  if (o_chld_nd.nodeValue && o_chld_nd.nodeValue.length && o_chld_nd.nodeType == 3) {			  	
				tmp_nd_val = o_chld_nd.nodeValue.toLowerCase();
				ni = GetWrdInd(tmp_nd_val,srch_word); 
			  if (ni>-1) { 
			  	wrd_count++; 
			  	if (wrd_count<3) { 
						m=1; 
						while(ni>-1) { 
							nv = o_chld_nd.nodeValue; 
							// preparin 
							before = document.createTextNode(nv.substr(0,ni)); 
							hi_txt = nv.substr(ni,srch_word.length); 
							after = document.createTextNode(nv.substr(ni+srch_word.length)); 
							hi_txt_nd = document.createTextNode(hi_txt); 
							hi_txt_nd_hold = document.createElement("A"); 
							with(hi_txt_nd_hold) { 
								style.cssText = "border-bottom:1px solid "+a_prm[1]+"; color:"+a_prm[1]+"; text-decoration:underline; cursor:pointer; ";
								setAttribute("tpi","1"); 
								setAttribute("href","about:blank"); 
								setAttribute("target","_blank"); 
								if (op)
									setAttribute("onmouseover","TTShow(event)"); 
								appendChild(hi_txt_nd); 
							} 
							AddEvntHandlers(hi_txt_nd_hold,a_evt_names,evHandlers);							
							// replacin
							//curWord=srch_word;
							with(o_pr_nd) {
								insertBefore(before,o_chld_nd);
								insertBefore(hi_txt_nd_hold,o_chld_nd);
								insertBefore(after,o_chld_nd);
								removeChild(o_chld_nd);
							}
							o_chld_nd = after;
							tmp_nd_val = o_chld_nd.nodeValue.toLowerCase();
							ni = GetWrdInd(tmp_nd_val,srch_word);
							m++;
							srch_word_cnt++;
			  		}
			  		i += m;
			 		}
			 	}
			}			
			HighlRecursive(o_chld_nd,srch_word);
		}
	}
	else
		return;
}


function GetWrdInd(text_data, word)
{	
	var srch_word = new RegExp(word, "ig");
	var signs = "\n\ ,.!?\"";
	var chr_before, chr_after, do_ret = 0;
	var tmp=0, add=0, val1=0, val2=text_data.length-1;
	try {
		while (!do_ret) {
			do_ret = 1;
			tmp = text_data.search(srch_word);	
			
			if (tmp > -1) {									
				if (!ie) {
					val1 = 2;
					val2 = text_data.length - 2;
				}
				
				if (tmp > val1) {
					chr_before = text_data.charAt(tmp-1);
					if (signs.indexOf(chr_before)==-1) 
						do_ret = 0;
				}	
				
				if ((tmp + word.length) <= val2) {			
					chr_after = text_data.charAt(tmp+word.length);
					if (signs.indexOf(chr_after)==-1) 
						do_ret = 0;				
				}
			}
			else
				add = 0;
			
			if (!do_ret) {
				add += tmp+word.length;
				text_data = text_data.substring(tmp+word.length,text_data.length);
			}
		}
		return (tmp + add);
	} catch(e) { 
		return -1; }
}


function GetWordId(word)
{
	if (!word || !a_words || !a_words_ids || a_words.length!=a_words_ids.length) return -1;
	
	for (i=0;i<a_words.length;i++)
		if (a_words[i].toLowerCase()==word.toLowerCase())
			return a_words_ids[i];
}


function DetectHeb(txt)
{
	var i, chr, b_heb = 0;
	if (!txt) return 0;
	for (i=0; i<txt.length && !b_heb; i++)
	{
		chr = txt.charCodeAt(i)
		if( chr >= 1488 && chr <= 1514 )
			b_heb = 1;
	}
	return b_heb;
}


function GetObj(s_id)
{
	return document.getElementById(s_id);
}


function AddEvntHandlers(o_trgt, a_ie_evt, a_handlers)
{
	var i;
	if(!o_trgt || !a_ie_evt || !a_handlers || a_ie_evt.length!=a_handlers.length) return;
	for (i=0;i<a_ie_evt.length;i++)
		if(ie && !op) 
			o_trgt.attachEvent(a_ie_evt[i],a_handlers[i]);
		else
			o_trgt.addEventListener(a_ie_evt[i].replace("on",""),a_handlers[i],true);
}

